{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "S+P Week 4 Exercise Question.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "code",
      "metadata": {
        "id": "GNkzTFfynsmV",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!pip install tensorflow==2.0.0b1"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "56XEQOGknrAk",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import tensorflow as tf\n",
        "print(tf.__version__)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "sLl52leVp5wU",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "def plot_series(time, series, format=\"-\", start=0, end=None):\n",
        "    plt.plot(time[start:end], series[start:end], format)\n",
        "    plt.xlabel(\"Time\")\n",
        "    plt.ylabel(\"Value\")\n",
        "    plt.grid(True)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "tP7oqUdkk0gY",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!wget --no-check-certificate \\\n",
        "    https://raw.githubusercontent.com/jbrownlee/Datasets/master/daily-min-temperatures.csv \\\n",
        "    -O /tmp/daily-min-temperatures.csv"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "NcG9r1eClbTh",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import csv\n",
        "time_step = []\n",
        "temps = []\n",
        "\n",
        "with open('/tmp/daily-min-temperatures.csv') as csvfile:\n",
        "# YOUR CODE HERE. READ TEMPERATURES INTO TEMPS\n",
        "# HAVE TIME STEPS BE A SIMPLE ARRAY OF 1, 2, 3, 4 etc\n",
        "\n",
        "series = np.array(temps)\n",
        "time = np.array(time_step)\n",
        "plt.figure(figsize=(10, 6))\n",
        "plot_series(time, series)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "L92YRw_IpCFG",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "split_time = 2500\n",
        "time_train = # YOUR CODE HERE\n",
        "x_train = # YOUR CODE HERE\n",
        "time_valid = # YOUR CODE HERE\n",
        "x_valid = # YOUR CODE HERE\n",
        "\n",
        "window_size = 30\n",
        "batch_size = 32\n",
        "shuffle_buffer_size = 1000\n",
        "\n"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lJwUUZscnG38",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "def windowed_dataset(series, window_size, batch_size, shuffle_buffer):\n",
        "    # YOUR CODE HERE"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "4XwGrf-A_wF0",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "def model_forecast(model, series, window_size):\n",
        "    # YOUR CODE HERE"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "AclfYY3Mn6Ph",
        "colab_type": "code",
        "outputId": "dd1fef93-d819-4d56-df20-330169907e16",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        }
      },
      "source": [
        "tf.keras.backend.clear_session()\n",
        "tf.random.set_seed(51)\n",
        "np.random.seed(51)\n",
        "window_size = 64\n",
        "batch_size = 256\n",
        "train_set = windowed_dataset(x_train, window_size, batch_size, shuffle_buffer_size)\n",
        "print(train_set)\n",
        "print(x_train.shape)\n",
        "\n",
        "model = tf.keras.models.Sequential([\n",
        "# YOUR CODE HERE\n",
        "])\n",
        "\n",
        "lr_schedule = tf.keras.callbacks.LearningRateScheduler(\n",
        "    lambda epoch: 1e-8 * 10**(epoch / 20))\n",
        "optimizer = tf.keras.optimizers.SGD(lr=1e-8, momentum=0.9)\n",
        "model.compile(loss=tf.keras.losses.Huber(),\n",
        "              optimizer=optimizer,\n",
        "              metrics=[\"mae\"])\n",
        "history = model.fit(train_set, epochs=100, callbacks=[lr_schedule])\n",
        "\n",
        "\n"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "WARNING: Logging before flag parsing goes to stderr.\n",
            "W0719 05:10:05.389573 140234944071552 deprecation.py:323] From /usr/local/lib/python3.6/dist-packages/tensorflow/python/data/util/random_seed.py:58: add_dispatch_support.<locals>.wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.\n",
            "Instructions for updating:\n",
            "Use tf.where in 2.0, which has the same broadcast rule as np.where\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "<PrefetchDataset shapes: ((None, None, 1), (None, None, 1)), types: (tf.float64, tf.float64)>\n",
            "(2500,)\n",
            "Epoch 1/100\n",
            "10/10 [==============================] - 6s 624ms/step - loss: 31.1549 - mae: 31.6551\n",
            "Epoch 2/100\n",
            "10/10 [==============================] - 4s 364ms/step - loss: 30.5696 - mae: 31.0771\n",
            "Epoch 3/100\n",
            "10/10 [==============================] - 4s 358ms/step - loss: 29.6691 - mae: 30.1811\n",
            "Epoch 4/100\n",
            "10/10 [==============================] - 4s 366ms/step - loss: 28.5431 - mae: 29.0596\n",
            "Epoch 5/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 27.1744 - mae: 27.6976\n",
            "Epoch 6/100\n",
            "10/10 [==============================] - 4s 367ms/step - loss: 25.4676 - mae: 26.0015\n",
            "Epoch 7/100\n",
            "10/10 [==============================] - 4s 375ms/step - loss: 23.2987 - mae: 23.8487\n",
            "Epoch 8/100\n",
            "10/10 [==============================] - 4s 369ms/step - loss: 20.5506 - mae: 21.1192\n",
            "Epoch 9/100\n",
            "10/10 [==============================] - 4s 372ms/step - loss: 17.2408 - mae: 17.8223\n",
            "Epoch 10/100\n",
            "10/10 [==============================] - 4s 365ms/step - loss: 13.5549 - mae: 14.1350\n",
            "Epoch 11/100\n",
            "10/10 [==============================] - 4s 370ms/step - loss: 10.0753 - mae: 10.6367\n",
            "Epoch 12/100\n",
            "10/10 [==============================] - 4s 365ms/step - loss: 7.5638 - mae: 8.0985\n",
            "Epoch 13/100\n",
            "10/10 [==============================] - 4s 363ms/step - loss: 6.2445 - mae: 6.7619\n",
            "Epoch 14/100\n",
            "10/10 [==============================] - 4s 374ms/step - loss: 5.6749 - mae: 6.1854\n",
            "Epoch 15/100\n",
            "10/10 [==============================] - 4s 363ms/step - loss: 5.3090 - mae: 5.8168\n",
            "Epoch 16/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 4.9122 - mae: 5.4169\n",
            "Epoch 17/100\n",
            "10/10 [==============================] - 4s 356ms/step - loss: 4.5318 - mae: 5.0305\n",
            "Epoch 18/100\n",
            "10/10 [==============================] - 4s 367ms/step - loss: 4.2115 - mae: 4.7068\n",
            "Epoch 19/100\n",
            "10/10 [==============================] - 4s 374ms/step - loss: 3.9429 - mae: 4.4360\n",
            "Epoch 20/100\n",
            "10/10 [==============================] - 4s 358ms/step - loss: 3.7309 - mae: 4.2194\n",
            "Epoch 21/100\n",
            "10/10 [==============================] - 4s 363ms/step - loss: 3.5706 - mae: 4.0551\n",
            "Epoch 22/100\n",
            "10/10 [==============================] - 4s 366ms/step - loss: 3.4527 - mae: 3.9344\n",
            "Epoch 23/100\n",
            "10/10 [==============================] - 4s 362ms/step - loss: 3.3617 - mae: 3.8423\n",
            "Epoch 24/100\n",
            "10/10 [==============================] - 4s 358ms/step - loss: 3.2876 - mae: 3.7666\n",
            "Epoch 25/100\n",
            "10/10 [==============================] - 3s 344ms/step - loss: 3.2224 - mae: 3.6997\n",
            "Epoch 26/100\n",
            "10/10 [==============================] - 4s 360ms/step - loss: 3.1596 - mae: 3.6359\n",
            "Epoch 27/100\n",
            "10/10 [==============================] - 4s 360ms/step - loss: 3.0964 - mae: 3.5717\n",
            "Epoch 28/100\n",
            "10/10 [==============================] - 4s 362ms/step - loss: 3.0322 - mae: 3.5064\n",
            "Epoch 29/100\n",
            "10/10 [==============================] - 4s 352ms/step - loss: 2.9662 - mae: 3.4392\n",
            "Epoch 30/100\n",
            "10/10 [==============================] - 4s 359ms/step - loss: 2.9004 - mae: 3.3720\n",
            "Epoch 31/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 2.8376 - mae: 3.3081\n",
            "Epoch 32/100\n",
            "10/10 [==============================] - 4s 375ms/step - loss: 2.7775 - mae: 3.2475\n",
            "Epoch 33/100\n",
            "10/10 [==============================] - 4s 360ms/step - loss: 2.7202 - mae: 3.1899\n",
            "Epoch 34/100\n",
            "10/10 [==============================] - 4s 367ms/step - loss: 2.6662 - mae: 3.1360\n",
            "Epoch 35/100\n",
            "10/10 [==============================] - 4s 379ms/step - loss: 2.6152 - mae: 3.0848\n",
            "Epoch 36/100\n",
            "10/10 [==============================] - 4s 357ms/step - loss: 2.5663 - mae: 3.0353\n",
            "Epoch 37/100\n",
            "10/10 [==============================] - 4s 366ms/step - loss: 2.5192 - mae: 2.9872\n",
            "Epoch 38/100\n",
            "10/10 [==============================] - 4s 367ms/step - loss: 2.4735 - mae: 2.9408\n",
            "Epoch 39/100\n",
            "10/10 [==============================] - 4s 372ms/step - loss: 2.4296 - mae: 2.8964\n",
            "Epoch 40/100\n",
            "10/10 [==============================] - 4s 371ms/step - loss: 2.3873 - mae: 2.8534\n",
            "Epoch 41/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 2.3463 - mae: 2.8119\n",
            "Epoch 42/100\n",
            "10/10 [==============================] - 4s 354ms/step - loss: 2.3060 - mae: 2.7707\n",
            "Epoch 43/100\n",
            "10/10 [==============================] - 4s 375ms/step - loss: 2.2663 - mae: 2.7301\n",
            "Epoch 44/100\n",
            "10/10 [==============================] - 4s 359ms/step - loss: 2.2269 - mae: 2.6899\n",
            "Epoch 45/100\n",
            "10/10 [==============================] - 4s 366ms/step - loss: 2.1898 - mae: 2.6519\n",
            "Epoch 46/100\n",
            "10/10 [==============================] - 4s 367ms/step - loss: 2.1563 - mae: 2.6181\n",
            "Epoch 47/100\n",
            "10/10 [==============================] - 4s 363ms/step - loss: 2.1248 - mae: 2.5861\n",
            "Epoch 48/100\n",
            "10/10 [==============================] - 4s 367ms/step - loss: 2.0958 - mae: 2.5568\n",
            "Epoch 49/100\n",
            "10/10 [==============================] - 4s 363ms/step - loss: 2.0688 - mae: 2.5296\n",
            "Epoch 50/100\n",
            "10/10 [==============================] - 4s 370ms/step - loss: 2.0442 - mae: 2.5045\n",
            "Epoch 51/100\n",
            "10/10 [==============================] - 4s 371ms/step - loss: 2.0220 - mae: 2.4818\n",
            "Epoch 52/100\n",
            "10/10 [==============================] - 4s 362ms/step - loss: 2.0018 - mae: 2.4611\n",
            "Epoch 53/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 1.9801 - mae: 2.4393\n",
            "Epoch 54/100\n",
            "10/10 [==============================] - 4s 369ms/step - loss: 1.9586 - mae: 2.4171\n",
            "Epoch 55/100\n",
            "10/10 [==============================] - 4s 358ms/step - loss: 1.9390 - mae: 2.3972\n",
            "Epoch 56/100\n",
            "10/10 [==============================] - 4s 366ms/step - loss: 1.9186 - mae: 2.3763\n",
            "Epoch 57/100\n",
            "10/10 [==============================] - 4s 366ms/step - loss: 1.8975 - mae: 2.3550\n",
            "Epoch 58/100\n",
            "10/10 [==============================] - 4s 359ms/step - loss: 1.8743 - mae: 2.3320\n",
            "Epoch 59/100\n",
            "10/10 [==============================] - 4s 363ms/step - loss: 1.8738 - mae: 2.3310\n",
            "Epoch 60/100\n",
            "10/10 [==============================] - 4s 354ms/step - loss: 2.1527 - mae: 2.6201\n",
            "Epoch 61/100\n",
            "10/10 [==============================] - 4s 357ms/step - loss: 2.6764 - mae: 3.1247\n",
            "Epoch 62/100\n",
            "10/10 [==============================] - 4s 360ms/step - loss: 2.9935 - mae: 3.4806\n",
            "Epoch 63/100\n",
            "10/10 [==============================] - 4s 360ms/step - loss: 3.5219 - mae: 3.9875\n",
            "Epoch 64/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 3.8284 - mae: 4.2965\n",
            "Epoch 65/100\n",
            "10/10 [==============================] - 4s 357ms/step - loss: 4.1265 - mae: 4.5856\n",
            "Epoch 66/100\n",
            "10/10 [==============================] - 4s 359ms/step - loss: 4.3062 - mae: 4.7664\n",
            "Epoch 67/100\n",
            "10/10 [==============================] - 4s 358ms/step - loss: 4.3039 - mae: 4.6838\n",
            "Epoch 68/100\n",
            "10/10 [==============================] - 4s 363ms/step - loss: 4.8341 - mae: 5.2257\n",
            "Epoch 69/100\n",
            "10/10 [==============================] - 4s 370ms/step - loss: 10.3352 - mae: 10.7649\n",
            "Epoch 70/100\n",
            "10/10 [==============================] - 4s 367ms/step - loss: 5.4020 - mae: 5.8328\n",
            "Epoch 71/100\n",
            "10/10 [==============================] - 4s 363ms/step - loss: 5.9798 - mae: 6.4835\n",
            "Epoch 72/100\n",
            "10/10 [==============================] - 4s 356ms/step - loss: 5.4958 - mae: 6.0146\n",
            "Epoch 73/100\n",
            "10/10 [==============================] - 4s 362ms/step - loss: 4.4955 - mae: 5.0201\n",
            "Epoch 74/100\n",
            "10/10 [==============================] - 4s 370ms/step - loss: 4.4764 - mae: 5.0171\n",
            "Epoch 75/100\n",
            "10/10 [==============================] - 4s 380ms/step - loss: 4.2825 - mae: 4.7287\n",
            "Epoch 76/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 4.2044 - mae: 4.6470\n",
            "Epoch 77/100\n",
            "10/10 [==============================] - 4s 370ms/step - loss: 4.4160 - mae: 4.9125\n",
            "Epoch 78/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 4.3770 - mae: 4.8831\n",
            "Epoch 79/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 5.0487 - mae: 5.5839\n",
            "Epoch 80/100\n",
            "10/10 [==============================] - 4s 390ms/step - loss: 10.0358 - mae: 10.8604\n",
            "Epoch 81/100\n",
            "10/10 [==============================] - 4s 370ms/step - loss: 3.1176 - mae: 3.6060\n",
            "Epoch 82/100\n",
            "10/10 [==============================] - 4s 371ms/step - loss: 3.0097 - mae: 3.4891\n",
            "Epoch 83/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 2.7912 - mae: 3.2609\n",
            "Epoch 84/100\n",
            "10/10 [==============================] - 4s 357ms/step - loss: 4.3135 - mae: 4.7803\n",
            "Epoch 85/100\n",
            "10/10 [==============================] - 4s 357ms/step - loss: 5.3703 - mae: 5.8508\n",
            "Epoch 86/100\n",
            "10/10 [==============================] - 4s 360ms/step - loss: 6.5221 - mae: 7.0175\n",
            "Epoch 87/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 7.1154 - mae: 7.7249\n",
            "Epoch 88/100\n",
            "10/10 [==============================] - 4s 368ms/step - loss: 8.9975 - mae: 9.4580\n",
            "Epoch 89/100\n",
            "10/10 [==============================] - 4s 360ms/step - loss: 9.8069 - mae: 10.1397\n",
            "Epoch 90/100\n",
            "10/10 [==============================] - 4s 354ms/step - loss: 11.1364 - mae: 11.6797\n",
            "Epoch 91/100\n",
            "10/10 [==============================] - 4s 356ms/step - loss: 12.5922 - mae: 13.2602\n",
            "Epoch 92/100\n",
            "10/10 [==============================] - 4s 357ms/step - loss: 14.2512 - mae: 14.8289\n",
            "Epoch 93/100\n",
            "10/10 [==============================] - 4s 358ms/step - loss: 13.0192 - mae: 13.8809\n",
            "Epoch 94/100\n",
            "10/10 [==============================] - 4s 356ms/step - loss: 61.8923 - mae: 63.5737\n",
            "Epoch 95/100\n",
            "10/10 [==============================] - 4s 366ms/step - loss: 30.5821 - mae: 31.4688\n",
            "Epoch 96/100\n",
            "10/10 [==============================] - 4s 357ms/step - loss: 45.9889 - mae: 46.9740\n",
            "Epoch 97/100\n",
            "10/10 [==============================] - 4s 355ms/step - loss: 51.7050 - mae: 51.8100\n",
            "Epoch 98/100\n",
            "10/10 [==============================] - 4s 361ms/step - loss: 59.1678 - mae: 57.9463\n",
            "Epoch 99/100\n",
            "10/10 [==============================] - 4s 373ms/step - loss: 66.1686 - mae: 68.4903\n",
            "Epoch 100/100\n",
            "10/10 [==============================] - 4s 360ms/step - loss: 74.1415 - mae: 72.0624\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "vVcKmg7Q_7rD",
        "colab_type": "code",
        "outputId": "5e9b8029-e996-4a2b-e016-666c69865b11",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 290
        }
      },
      "source": [
        "plt.semilogx(history.history[\"lr\"], history.history[\"loss\"])\n",
        "plt.axis([1e-8, 1e-4, 0, 60])"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[1e-08, 0.0001, 0, 60]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 13
        },
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEACAYAAABfxaZOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAHxdJREFUeJzt3Xl4XNWZ5/HvW4v2zbJled+wwdjg\nBYRZEwhbCEMC6SYkhE5M4hk3PTNZms4EpjN00tPdk6STJ3syhCEkzh5CSEyAsMSBQMYGLOMFLyy2\n8b5blmxZllSlevuPKsnG2FZJqlJV+f4+z6On6p66Vff1sfS7t06de8vcHRERCYZQrgsQEZHBo9AX\nEQkQhb6ISIAo9EVEAkShLyISIAp9EZEASSv0zazGzB4ys1fNbJ2ZXWxmtWb2tJm9kbodku1iRURk\nYNI90v8m8IS7TwVmAuuAu4FF7j4FWJRaFhGRPGa9nZxlZtXACmCSH7Oymb0GXOHu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Z2YhM/s3M/u2mc3NdT2FzsyuMLPnU7+jV+S6\nnkJnZuVm1mhmN6Sz/oBDPxXUe44/07aPF2M7F3jI3T8OzB5oTYUsE/3p7s+7+x3Ao8CCbNab7zL0\n+3kjyfNQYiTPPA+sDPWnA61ACQHuzwz1JcBdwINpb3egs3fM7J0k/wN/7O7npNrCJOfwX0PyP3Up\ncCvJqZ1fPO4lPg50AQ+R/GX4ibv/cEBFFbBM9Ke770k970FgnrsfGqTy806Gfj8/Dhxw9++b2UPu\nfvNg1Z9vMtSf+9w9YWb1wNfc/bbBqj+fZKgvZwJDSe5A97n7o71td8DfnOXuz5nZhOOaey7GBmBm\nvwRudPcvAm97C2JmnwE+n3qth4DAhn4m+jO1zjigJciBDxn7/dwGdKYWu7JXbf7L1O9nygGgOBt1\nFoIM/W5eAZSTvNLxETN73N0Tp9putr4uMa2LsR3jCeALZvZhYFOWaipkfe1PgHkEeOfZi77258PA\nt83sHcBz2SysQPWpP83sr4B3AzXAd7JbWsHpU1+6++cAzOx2Uu+gettAXnxHrruvJnkBN8kQd/98\nrms4Xbh7G8mdqGSAuz9MckcqGeLuP0p33WzN3snXi7EVKvVnZqk/M0v9mTlZ78tshf5SYIqZTTSz\nIuBDwCNZ2lYQqD8zS/2ZWerPzMl6X2ZiyuYvgCXAWWa2zczmuXsc6L4Y2zrgwTQuxiaoPzNN/ZlZ\n6s/MyVVf6oJrIiIBkhdn5IqIyOBQ6IuIBIhCX0QkQBT6IiIBotAXEQkQhb6ISIAo9EVEAkShLyIS\nIAp9EZEA+Q/EvnPaR7UhDAAAAABJRU5ErkJggg==\n",
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "QsksvkcXAAgq",
        "colab_type": "code",
        "outputId": "70263fd4-3c3a-4e93-a451-ee942131e0d4",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        }
      },
      "source": [
        "tf.keras.backend.clear_session()\n",
        "tf.random.set_seed(51)\n",
        "np.random.seed(51)\n",
        "train_set = windowed_dataset(x_train, window_size=60, batch_size=100, shuffle_buffer=shuffle_buffer_size)\n",
        "model = tf.keras.models.Sequential([\n",
        "# YOUR CODE HERE\n",
        "])\n",
        "\n",
        "\n",
        "optimizer = tf.keras.optimizers.SGD(lr=# YOUR CODE HERE, momentum=0.9)\n",
        "model.compile(loss=tf.keras.losses.Huber(),\n",
        "              optimizer=optimizer,\n",
        "              metrics=[\"mae\"])\n",
        "history = model.fit(train_set,epochs=# YOUR CODE HERE)\n",
        "                                    \n",
        "# EXPECTED OUTPUT SHOULD SEE AN MAE OF <2 WITHIN ABOUT 30 EPOCHS"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Epoch 1/150\n",
            "25/25 [==============================] - 6s 243ms/step - loss: 9.9624 - mae: 10.5789\n",
            "Epoch 2/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 2.5390 - mae: 3.0130\n",
            "Epoch 3/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.9265 - mae: 2.3815\n",
            "Epoch 4/150\n",
            "25/25 [==============================] - 3s 137ms/step - loss: 1.8597 - mae: 2.3125\n",
            "Epoch 5/150\n",
            "25/25 [==============================] - 3s 139ms/step - loss: 1.8181 - mae: 2.2696\n",
            "Epoch 6/150\n",
            "25/25 [==============================] - 3s 140ms/step - loss: 1.7882 - mae: 2.2385\n",
            "Epoch 7/150\n",
            "25/25 [==============================] - 4s 141ms/step - loss: 1.7618 - mae: 2.2112\n",
            "Epoch 8/150\n",
            "25/25 [==============================] - 3s 135ms/step - loss: 1.7382 - mae: 2.1870\n",
            "Epoch 9/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.7167 - mae: 2.1650\n",
            "Epoch 10/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.6976 - mae: 2.1454\n",
            "Epoch 11/150\n",
            "25/25 [==============================] - 3s 138ms/step - loss: 1.6808 - mae: 2.1281\n",
            "Epoch 12/150\n",
            "25/25 [==============================] - 3s 138ms/step - loss: 1.6661 - mae: 2.1128\n",
            "Epoch 13/150\n",
            "25/25 [==============================] - 4s 142ms/step - loss: 1.6531 - mae: 2.0993\n",
            "Epoch 14/150\n",
            "25/25 [==============================] - 4s 142ms/step - loss: 1.6417 - mae: 2.0872\n",
            "Epoch 15/150\n",
            "25/25 [==============================] - 3s 135ms/step - loss: 1.6315 - mae: 2.0764\n",
            "Epoch 16/150\n",
            "25/25 [==============================] - 3s 128ms/step - loss: 1.6223 - mae: 2.0667\n",
            "Epoch 17/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.6141 - mae: 2.0579\n",
            "Epoch 18/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.6067 - mae: 2.0500\n",
            "Epoch 19/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.6000 - mae: 2.0429\n",
            "Epoch 20/150\n",
            "25/25 [==============================] - 3s 138ms/step - loss: 1.5939 - mae: 2.0364\n",
            "Epoch 21/150\n",
            "25/25 [==============================] - 3s 137ms/step - loss: 1.5883 - mae: 2.0306\n",
            "Epoch 22/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.5833 - mae: 2.0254\n",
            "Epoch 23/150\n",
            "25/25 [==============================] - 4s 141ms/step - loss: 1.5787 - mae: 2.0207\n",
            "Epoch 24/150\n",
            "25/25 [==============================] - 3s 140ms/step - loss: 1.5745 - mae: 2.0163\n",
            "Epoch 25/150\n",
            "25/25 [==============================] - 4s 141ms/step - loss: 1.5707 - mae: 2.0124\n",
            "Epoch 26/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.5672 - mae: 2.0089\n",
            "Epoch 27/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.5640 - mae: 2.0056\n",
            "Epoch 28/150\n",
            "25/25 [==============================] - 3s 135ms/step - loss: 1.5610 - mae: 2.0026\n",
            "Epoch 29/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.5583 - mae: 1.9998\n",
            "Epoch 30/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.5558 - mae: 1.9973\n",
            "Epoch 31/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.5534 - mae: 1.9949\n",
            "Epoch 32/150\n",
            "25/25 [==============================] - 3s 139ms/step - loss: 1.5512 - mae: 1.9927\n",
            "Epoch 33/150\n",
            "25/25 [==============================] - 3s 139ms/step - loss: 1.5491 - mae: 1.9906\n",
            "Epoch 34/150\n",
            "25/25 [==============================] - 3s 138ms/step - loss: 1.5472 - mae: 1.9886\n",
            "Epoch 35/150\n",
            "25/25 [==============================] - 4s 140ms/step - loss: 1.5453 - mae: 1.9868\n",
            "Epoch 36/150\n",
            "25/25 [==============================] - 4s 141ms/step - loss: 1.5436 - mae: 1.9850\n",
            "Epoch 37/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.5419 - mae: 1.9833\n",
            "Epoch 38/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.5404 - mae: 1.9817\n",
            "Epoch 39/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.5389 - mae: 1.9803\n",
            "Epoch 40/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.5376 - mae: 1.9789\n",
            "Epoch 41/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.5363 - mae: 1.9776\n",
            "Epoch 42/150\n",
            "25/25 [==============================] - 3s 129ms/step - loss: 1.5350 - mae: 1.9764\n",
            "Epoch 43/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.5338 - mae: 1.9752\n",
            "Epoch 44/150\n",
            "25/25 [==============================] - 4s 140ms/step - loss: 1.5327 - mae: 1.9741\n",
            "Epoch 45/150\n",
            "25/25 [==============================] - 4s 141ms/step - loss: 1.5316 - mae: 1.9730\n",
            "Epoch 46/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.5305 - mae: 1.9719\n",
            "Epoch 47/150\n",
            "25/25 [==============================] - 3s 135ms/step - loss: 1.5295 - mae: 1.9708\n",
            "Epoch 48/150\n",
            "25/25 [==============================] - 3s 138ms/step - loss: 1.5286 - mae: 1.9698\n",
            "Epoch 49/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.5276 - mae: 1.9689\n",
            "Epoch 50/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.5267 - mae: 1.9680\n",
            "Epoch 51/150\n",
            "25/25 [==============================] - 3s 139ms/step - loss: 1.5259 - mae: 1.9672\n",
            "Epoch 52/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.5251 - mae: 1.9664\n",
            "Epoch 53/150\n",
            "25/25 [==============================] - 3s 135ms/step - loss: 1.5243 - mae: 1.9656\n",
            "Epoch 54/150\n",
            "25/25 [==============================] - 3s 137ms/step - loss: 1.5235 - mae: 1.9648\n",
            "Epoch 55/150\n",
            "25/25 [==============================] - 3s 137ms/step - loss: 1.5228 - mae: 1.9640\n",
            "Epoch 56/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.5221 - mae: 1.9633\n",
            "Epoch 57/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.5213 - mae: 1.9626\n",
            "Epoch 58/150\n",
            "25/25 [==============================] - 3s 137ms/step - loss: 1.5206 - mae: 1.9619\n",
            "Epoch 59/150\n",
            "25/25 [==============================] - 3s 135ms/step - loss: 1.5199 - mae: 1.9611\n",
            "Epoch 60/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.5193 - mae: 1.9604\n",
            "Epoch 61/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.5186 - mae: 1.9597\n",
            "Epoch 62/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.5179 - mae: 1.9589\n",
            "Epoch 63/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.5173 - mae: 1.9582\n",
            "Epoch 64/150\n",
            "25/25 [==============================] - 3s 135ms/step - loss: 1.5166 - mae: 1.9576\n",
            "Epoch 65/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.5161 - mae: 1.9570\n",
            "Epoch 66/150\n",
            "25/25 [==============================] - 3s 138ms/step - loss: 1.5155 - mae: 1.9564\n",
            "Epoch 67/150\n",
            "25/25 [==============================] - 3s 140ms/step - loss: 1.5149 - mae: 1.9557\n",
            "Epoch 68/150\n",
            "25/25 [==============================] - 4s 141ms/step - loss: 1.5142 - mae: 1.9550\n",
            "Epoch 69/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.5136 - mae: 1.9543\n",
            "Epoch 70/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.5129 - mae: 1.9536\n",
            "Epoch 71/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.5122 - mae: 1.9528\n",
            "Epoch 72/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.5115 - mae: 1.9521\n",
            "Epoch 73/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.5108 - mae: 1.9514\n",
            "Epoch 74/150\n",
            "25/25 [==============================] - 3s 135ms/step - loss: 1.5102 - mae: 1.9508\n",
            "Epoch 75/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.5097 - mae: 1.9503\n",
            "Epoch 76/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.5091 - mae: 1.9497\n",
            "Epoch 77/150\n",
            "25/25 [==============================] - 3s 137ms/step - loss: 1.5084 - mae: 1.9491\n",
            "Epoch 78/150\n",
            "25/25 [==============================] - 3s 128ms/step - loss: 1.5078 - mae: 1.9485\n",
            "Epoch 79/150\n",
            "25/25 [==============================] - 3s 129ms/step - loss: 1.5072 - mae: 1.9478\n",
            "Epoch 80/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.5065 - mae: 1.9471\n",
            "Epoch 81/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.5059 - mae: 1.9465\n",
            "Epoch 82/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.5053 - mae: 1.9459\n",
            "Epoch 83/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.5048 - mae: 1.9454\n",
            "Epoch 84/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.5043 - mae: 1.9448\n",
            "Epoch 85/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.5038 - mae: 1.9443\n",
            "Epoch 86/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.5033 - mae: 1.9438\n",
            "Epoch 87/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.5028 - mae: 1.9433\n",
            "Epoch 88/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.5023 - mae: 1.9428\n",
            "Epoch 89/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.5017 - mae: 1.9422\n",
            "Epoch 90/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.5012 - mae: 1.9416\n",
            "Epoch 91/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.5004 - mae: 1.9408\n",
            "Epoch 92/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.4992 - mae: 1.9396\n",
            "Epoch 93/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.4982 - mae: 1.9386\n",
            "Epoch 94/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.4975 - mae: 1.9378\n",
            "Epoch 95/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.4968 - mae: 1.9371\n",
            "Epoch 96/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.4962 - mae: 1.9364\n",
            "Epoch 97/150\n",
            "25/25 [==============================] - 3s 137ms/step - loss: 1.4955 - mae: 1.9358\n",
            "Epoch 98/150\n",
            "25/25 [==============================] - 3s 140ms/step - loss: 1.4949 - mae: 1.9351\n",
            "Epoch 99/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.4942 - mae: 1.9344\n",
            "Epoch 100/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.4934 - mae: 1.9336\n",
            "Epoch 101/150\n",
            "25/25 [==============================] - 3s 135ms/step - loss: 1.4927 - mae: 1.9328\n",
            "Epoch 102/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.4919 - mae: 1.9319\n",
            "Epoch 103/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.4913 - mae: 1.9313\n",
            "Epoch 104/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.4908 - mae: 1.9307\n",
            "Epoch 105/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.4903 - mae: 1.9302\n",
            "Epoch 106/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.4899 - mae: 1.9298\n",
            "Epoch 107/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.4895 - mae: 1.9293\n",
            "Epoch 108/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.4892 - mae: 1.9289\n",
            "Epoch 109/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.4888 - mae: 1.9285\n",
            "Epoch 110/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.4884 - mae: 1.9282\n",
            "Epoch 111/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.4881 - mae: 1.9278\n",
            "Epoch 112/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.4878 - mae: 1.9275\n",
            "Epoch 113/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.4874 - mae: 1.9271\n",
            "Epoch 114/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.4871 - mae: 1.9268\n",
            "Epoch 115/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.4868 - mae: 1.9265\n",
            "Epoch 116/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.4865 - mae: 1.9262\n",
            "Epoch 117/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.4862 - mae: 1.9258\n",
            "Epoch 118/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.4859 - mae: 1.9255\n",
            "Epoch 119/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.4856 - mae: 1.9252\n",
            "Epoch 120/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.4853 - mae: 1.9249\n",
            "Epoch 121/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.4851 - mae: 1.9247\n",
            "Epoch 122/150\n",
            "25/25 [==============================] - 3s 135ms/step - loss: 1.4848 - mae: 1.9243\n",
            "Epoch 123/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.4845 - mae: 1.9240\n",
            "Epoch 124/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.4842 - mae: 1.9238\n",
            "Epoch 125/150\n",
            "25/25 [==============================] - 3s 133ms/step - loss: 1.4840 - mae: 1.9235\n",
            "Epoch 126/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.4838 - mae: 1.9232\n",
            "Epoch 127/150\n",
            "25/25 [==============================] - 3s 129ms/step - loss: 1.4835 - mae: 1.9230\n",
            "Epoch 128/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.4833 - mae: 1.9228\n",
            "Epoch 129/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.4831 - mae: 1.9225\n",
            "Epoch 130/150\n",
            "25/25 [==============================] - 3s 129ms/step - loss: 1.4828 - mae: 1.9222\n",
            "Epoch 131/150\n",
            "25/25 [==============================] - 3s 128ms/step - loss: 1.4826 - mae: 1.9220\n",
            "Epoch 132/150\n",
            "25/25 [==============================] - 3s 127ms/step - loss: 1.4823 - mae: 1.9217\n",
            "Epoch 133/150\n",
            "25/25 [==============================] - 3s 129ms/step - loss: 1.4821 - mae: 1.9214\n",
            "Epoch 134/150\n",
            "25/25 [==============================] - 3s 129ms/step - loss: 1.4818 - mae: 1.9212\n",
            "Epoch 135/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.4815 - mae: 1.9209\n",
            "Epoch 136/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.4813 - mae: 1.9206\n",
            "Epoch 137/150\n",
            "25/25 [==============================] - 3s 127ms/step - loss: 1.4811 - mae: 1.9204\n",
            "Epoch 138/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.4808 - mae: 1.9201\n",
            "Epoch 139/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.4806 - mae: 1.9199\n",
            "Epoch 140/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.4804 - mae: 1.9197\n",
            "Epoch 141/150\n",
            "25/25 [==============================] - 3s 132ms/step - loss: 1.4802 - mae: 1.9194\n",
            "Epoch 142/150\n",
            "25/25 [==============================] - 3s 129ms/step - loss: 1.4799 - mae: 1.9192\n",
            "Epoch 143/150\n",
            "25/25 [==============================] - 3s 134ms/step - loss: 1.4797 - mae: 1.9189\n",
            "Epoch 144/150\n",
            "25/25 [==============================] - 3s 135ms/step - loss: 1.4795 - mae: 1.9187\n",
            "Epoch 145/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.4794 - mae: 1.9185\n",
            "Epoch 146/150\n",
            "25/25 [==============================] - 3s 131ms/step - loss: 1.4791 - mae: 1.9183\n",
            "Epoch 147/150\n",
            "25/25 [==============================] - 3s 130ms/step - loss: 1.4789 - mae: 1.9180\n",
            "Epoch 148/150\n",
            "25/25 [==============================] - 3s 136ms/step - loss: 1.4787 - mae: 1.9178\n",
            "Epoch 149/150\n",
            "25/25 [==============================] - 3s 137ms/step - loss: 1.4784 - mae: 1.9175\n",
            "Epoch 150/150\n",
            "25/25 [==============================] - 4s 143ms/step - loss: 1.4782 - mae: 1.9173\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "GaC6NNMRp0lb",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "rnn_forecast = model_forecast(model, series[..., np.newaxis], window_size)\n",
        "rnn_forecast = rnn_forecast[split_time - window_size:-1, -1, 0]"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "id": "izy6wl2S9d-2",
        "colab": {}
      },
      "source": [
        "plt.figure(figsize=(10, 6))\n",
        "plot_series(time_valid, x_valid)\n",
        "plot_series(time_valid, rnn_forecast)\n",
        "\n",
        "# EXPECTED OUTPUT. PLOT SHOULD SHOW PROJECTIONS FOLLOWING ORIGINAL DATA CLOSELY"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "13XrorC5wQoE",
        "colab_type": "code",
        "outputId": "7f5bda4a-160c-4c0f-e511-a5a1b6945d35",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        }
      },
      "source": [
        "tf.keras.metrics.mean_absolute_error(x_valid, rnn_forecast).numpy()\n",
        "\n",
        "# EXPECTED OUTPUT MAE < 2 -- I GOT 1.789626"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "1.780626"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 18
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "AOVzQXxCwkzP",
        "colab_type": "code",
        "outputId": "3b3fd11c-f9b3-4cbd-e32d-2d7d22b6ff7f",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        }
      },
      "source": [
        "print(rnn_forecast)\n",
        "# EXPECTED OUTPUT -- ARRAY OF VALUES IN THE LOW TEENS"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "[11.636601 10.97607  12.159701 ... 13.589686 13.726407 14.940471]\n"
          ],
          "name": "stdout"
        }
      ]
    }
  ]
}